package com.example.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.LongAdder;

/**
 * @ClassName MyController
 * @Description TODO
 * @Author: XMK
 * @Date: 2021/7/27 16:56
 * @Version: 1.0
 */
@RestController
public class MyController {

    private LongAdder longAdder = new LongAdder();
    private AtomicLong atomicLong = new AtomicLong(0);

    @PostMapping("/jmeter")
    public String jmeter(@RequestParam String  p) {

        System.out.println(p);
        try {
            Thread.sleep(300);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        return "aa";
    }

    @PostMapping("/longadder")
    public long testLongadder() {

        longAdder.increment();

        return longAdder.longValue();
    }

    @PostMapping("/atomiclong")
    public long testAtomiclong() {

        atomicLong.incrementAndGet();

        return atomicLong.longValue();
    }
}
